#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = "HuJiang";

from django.db import models;
import datetime;

'''
Spider 模块 entity 定义
'''

class Double_Color_Ball_1(models.Model):
    # ---- 主键列 ----
    id = models.AutoField(primary_key=True);
    # ---- 非主键列 ----
    issue_no = models.CharField(name="issue_no", max_length=255, blank = False, null = False);
    award_date = models.DateField(name="award_date", blank = True, null = True);
    red_ball = models.CharField(name="red_ball", max_length=255, blank = False, null = False);
    blue_ball = models.CharField(name="blue_ball", max_length=255, blank = False, null = False);
    total_sales = models.FloatField(name="total_sales", blank = True, null = True);
    first_prize_number = models.IntegerField(name="first_prize_number", blank = True, null = True);
    second_prize_number = models.IntegerField(name="second_prize_number", blank = True, null = True);
    create_date = models.DateTimeField(auto_now=True, blank = True, null = True);

    def dcb_dict(self):
        dcb_dict = {};
        dcb_dict["id"] = self.id;
        dcb_dict["issueNo"] = self.issue_no;
        dcb_dict["redBall"] = self.red_ball;
        dcb_dict["blueBall"] = self.blue_ball;
        dcb_dict["totalSales"] = self.total_sales;
        dcb_dict["firstPrizeNumber"] = self.first_prize_number;
        dcb_dict["secondPrizeNumber"] = self.second_prize_number;
        if self.create_date:
            dcb_dict["createDate"] = self.create_date.strftime("%Y-%m-%d %H:%M:%S");
        return dcb_dict;

    # 指定表名，若不指定，默认生成表名为：app名称_类名，比如account_user
    class Meta:
        db_table = ('double_color_ball');